<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>title</title>
  <!--按顺序引入-->
  <script src="https://cdn.staticfile.org/react/16.8.4/umd/react.development.js"></script>
  <script src="https://cdn.staticfile.org/react-dom/16.8.4/umd/react-dom.development.js"></script>
  <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
  <script src="../js/babel.min.js"></script>
  <script src="https://cdn.bootcdn.net/ajax/libs/prop-types/15.8.1/prop-types.js"></script>
  <style>
    body {
      width: 95vw;
      height: 80vh;
      background-color: #2b2b2b;
      color: wheat;
    }
  </style>
</head>
<body>
<div id="app"></div>

<script type="text/babel">
  // 类式组件
  class Person extends React.Component {
    render() {
      return (
        <ul>
          <li>name: {this.props.name}</li>
          <li>sex: {this.props.sex}</li>
          <li>age: {this.props.age + 1}</li>
        </ul>
      )
    }
  }

  // props类型限制 需额外引入相关的库
  Person.propTypes = {
    name: PropTypes.string.isRequired,
    age: PropTypes.number, // 数字
    sex: PropTypes.string, // 字符串
    speak: PropTypes.func //方法
  }
  // props默认值
  Person.defaultProps = {
    sex: '男'
  }

  //const p = {name: 'Tom', age: 19, sex: '男'}
  //ReactDOM.render(<Weather {...p}/>, document.getElementById('app'))

  function speak() {
    console.log(1)
  }

  ReactDOM.render(<Person name='Tom' age={18} speak={speak} />, document.getElementById('app'))
</script>
</body>
</html>
